from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib.sites.models import Site
from tagging.views import tagged_object_list
from models import Entry

site = Site.objects.get(id=settings.SITE_ID)

entry_dict = {
    'queryset': Entry.published_objects.filter(weblog__site = settings.SITE_ID),
    'date_field': 'pub_date',
}

urlpatterns = patterns ('',
    (r'tag/(?P<tag>[^/]+(?u))/$', tagged_object_list,
     dict(model = Entry, paginate_by = 10, allow_empty = True)),
    
    # Views for all weblogs
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 
     'django.views.generic.date_based.archive_day', dict(entry_dict, template_name = 'blogs/weblog_archive_day.html', extra_context={'site': site,})),
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'django.views.generic.date_based.archive_month', 
     dict(entry_dict, template_name = 'blogs/weblog_archive_month.html', extra_context={'site': site,})),
    (r'^(?P<year>\d{4})/$', 'django.views.generic.date_based.archive_year', dict(entry_dict, make_object_list = True, template_name = 'blogs/weblog_archive_year.html', extra_context={'site': site,})),
    (r'^today/$', 'django.views.generic.date_based.archive_today', dict(entry_dict, template_name = 'blogs/weblog_archive_day.html', extra_context={'site': site,})),
    (r'^/?$', 'django.views.generic.date_based.archive_index', dict(entry_dict, template_name = 'blogs/weblog_archive.html', extra_context={'site': site,})),
    
    # Individual weblog views
    (r'^(?P<weblog>[-\w]+)/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$',
     'clapton.apps.blogs.views.object_detail'),
    (r'^(?P<weblog>[-\w]+)/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 
     'clapton.apps.blogs.views.archive_day'),
    (r'^(?P<weblog>[-\w]+)/(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'clapton.apps.blogs.views.archive_month'),
    (r'^(?P<weblog>[-\w]+)/(?P<year>\d{4})/$', 'clapton.apps.blogs.views.archive_year'),
    (r'^(?P<weblog>[-\w]+)/today/$', 'clapton.apps.blogs.views.archive_today'),
    (r'^(?P<weblog>[-\w]+)/$', 'clapton.apps.blogs.views.archive_index'),
)
